/*******************************************************************************
 ** Name: character.cpp                                                       **
 ** Description:                                                              **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved CDDL License                        **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry Gian James  <bjames@gamingods.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 **  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      **
 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED **
 ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           **
 ** PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT        **
 ** HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    **
 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  **
 ** TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR    **
 ** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    **
 ** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      **
 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        **
 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              **
 **                                                                           **
 ******************************************************************************/
// Modified $Date$ by $Author$
#define _character_cpp_ID    "$Id$"

#include "character.hpp"
#include "condition.hpp"
#include "team.hpp"

const char  *    GenderStr[] = { "male", "female", "androgenous", "transgendered" };

WearLocations::WearLocations()
{
	head = larm = rarm = lleg = rleg = chest = back = feet = neck = 0;
	waist = lfinger = rfinger = legs = lhand = rhand = lwrist = rwrist = 0;
}

////////////////////////////////[ Character

bool
Character::Wielding()
{
	if (_wearLocations.lhand != 0 || _wearLocations.rhand != 0)
		return (true);
	else
		return (false);
}

void
Character::accept(Pattern::Visitor & v)
{

}

void
Character::UpdateStats()
{
	// TODO
}

int
Character::Actionable()
{	// TODO
	return (0);
}



Character::Character(const std::string & n, const std::string & t, ObjectType tt)
        : WorldObject(tt,n,t)
{
    _xp = 0; _scratch = 1000;
    _lvl = 1;
    _str = _dex = _con = _inte = _aur = _wit = _wil = _gen = DEFAULT_STAT;
    _str_max = _dex_max = _con_max = _inte_max = 0;
    _aur_max = _wit_max = _wil_max = _gen_max = 0;
    _def = _avd = _init = 0;
    _def_max = _avd_max = _init_max = _speed_max = 0;
    _speed = 30;
    _fort = _will = _reflex = _recovery = 0;
    _consider = 0.0;
    _gender = GenderType::Male;
     _loc = 0;
}

Character::Character()
        : WorldObject()
{
    _xp = 0; _scratch = 1000;
    _lvl = 1;
    _str = _dex = _con = _inte = _aur = _wit = _wil = _gen = DEFAULT_STAT;
    _str_max = _dex_max = _con_max = _inte_max = 0;
    _aur_max = _wit_max = _wil_max = _gen_max = 0;
    _def = _avd = _init = 0;
    _def_max = _avd_max = _init_max = _speed_max = 0;
    _speed = 30;
    _fort = _will = _reflex = _recovery = 0;
    _consider = 0.0;
    _gender = GenderType::Male;
     _loc = 0;
}

Character::Character(const Character& orig)
{	// TODO
}

Character::~Character()
{
}

//////////////////////////////////////////////[ PC
PC::PC()
: Character()
{
	_bkglvl = _pkills = _pdeaths = 0;
	_rank = 1; _on_team = false;
}


PC::PC(const std::string & n, const std::string & t)
: Character(n,t,ObjectType::PC)
{
	PC();
}

bool
PC::QuestCompleted(std::string & q)
{
	return (false);
}

void
PC::AddQuest(entity_t)
{

}

void
PC::CompleteQuest(entity_t)
{

}

void
PC::accept(Pattern::Visitor & v)
{

}

void
PC::StartTeam(const std::string & n)
{
	_team = Team::Create(n);	// dynamically controls alloc of channel
	_team->AddMember(shared_from_this());
	_team->SendToTeamChannel("You have created a team.");
	_on_team = true;
}

void
PC::JoinTeam(Team::pointer t) {
	_team = t;
	_team->AddMember(shared_from_this());
	_on_team = true;
}

void
PC::LeaveTeam()
{
	_team->RemoveMember(shared_from_this());
	_team = shared_null_ptr_t;
	_on_team = false;
}

void
PC::deliver(const std::string & msg)
{

}

//////////////////////////////////////////////[ Dossier


